# Definition for singly-linked list.
class ListNode(object):
    def __init__(self, x):
        self.val = x
        self.next = None

class Solution(object):
    def oddEvenList(self, head):
        """
        :type head: ListNode
        :rtype: ListNode
        """
        if not head:
            return None

        o = head.next
        j =head
        t = o

        while o and o.next:
            j.next = o.next
            j = j.next
            o.next = o.next.next
            o = o.next
        j.next = t
        return head
